/**
 * Created by liusonglin on 2018/7/12.
 */
import React, {Component, lazy, Suspense} from 'react';
import {BrowserRouter as Router, Redirect, Route as NoAuthRoute, Switch} from 'react-router-dom'
import Route from './PrivateRoute'
import {Spin} from "antd";
import Login from "../components/login";
import MainLayout from "../components/main/layout/MainLayout";

const IndexView = lazy(() => import('./IndexView'))
const Demo = lazy(() =>   import("../commons/components/Demo"))
const HomePage = lazy(() =>  import("../components/homePage"))
const CorporationTable = lazy(() =>  import("../components/baf/Corporation/CorporationTable"))
const OrganizationView = lazy(() =>  import("../components/baf/Organization/OrganizationView"))
const PositionCategoryTable = lazy(() =>  import("../components/baf/PositionCategoryManagement/PositionCategoryTable"))
const PositionView = lazy(() =>  import("../components/baf/Position/PositionView"))
const CountryTable = lazy(() =>  import("../components/baf/Country/CountryTable"))
const RegionView = lazy(() =>  import("../components/baf/Region/RegionView"))
const ProfessionalDomainView = lazy(() =>  import("../components/baf/ProfessionalDomain/ProfessionalDomainView"))
const AppModuleTable = lazy(() =>  import("../components/baf/AppModule/AppModuleTable"))
const AuthorizeEntityTypeTable = lazy(() =>  import("../components/baf/AuthorizeEntityType/AuthorizeEntityTypeTable"))
const DataAuthorizeTypeTable = lazy(() =>  import("../components/baf/DataAuthorizeType/DataAuthorizeTypeTable"))
const TenantTable = lazy(() =>  import("../components/baf/Tenant/TenantTable"))
const FeatureView = lazy(() =>  import("../components/baf/Feature/FeatureView"))
const FeatureRoleView = lazy(() =>  import("../components/baf/FeatureRole/FeatureRoleView"))
const DataAuthorizationView = lazy(() =>  import("../components/baf/DataAuthorization/DataAuthorizationView"))
const MenuView = lazy(() =>  import("../components/baf/Menu/MenuView"))
const EnterpriseUserView = lazy(() =>  import("../components/baf/EnterpriseUser/EnterpriseUserView"))
const SupplierUserTable = lazy(() =>  import("../components/baf/SupplierUser/SupplierUserTable"))
const ExpertUserTable = lazy(() =>  import("../components/baf/ExpertUser/ExpertUserTable"))
const DataRoleManagerView = lazy(() =>  import("../components/baf/DataRole/DataRoleManagerView"))
const Test = lazy(() => import('../components/main/layout/Test'));
const UserSetting = lazy(() => import('../components/userSetting'));
const NoAuthorized = lazy(() => import('../components/noAuthorized/index.jsx'));
const DataDictionary = lazy(() => import('../components/baf/dataDictionary/index.jsx'));

export default class Routers extends Component {
    render() {
        return (
            <Router basename="/react-basic-web">
                <Suspense
                    fallback={<Spin/>}
                >
                    <Switch>
                        <NoAuthRoute path="/login" component={Login}/>
                        <Route path="/homePage"  component={HomePage}/>
                        <NoAuthRoute path="/index" component={MainLayout}/>
                        <Route path="/userSetting" component={UserSetting}/>
                        {/*后台配置*/}
                        <Route path='/AppModuleTable' component={AppModuleTable}/>
                        <Route path='/FeatureView' component={FeatureView}/>
                        <Route path='/MenuView' component={MenuView}/>
                        <Route path='/AuthorizeEntityTypeTable' component={AuthorizeEntityTypeTable}/>
                        <Route path='/DataAuthorizeTypeTable' component={DataAuthorizeTypeTable}/>
                        <Route path='/DataDictionary' component={DataDictionary}/>
                        {/*组织架构*/}
                        <Route path='/home' exact component={IndexView}/>
                        <Route path='/Demo' component={Demo}/>
                        <Route path='/CorporationTable' component={CorporationTable}/>
                        <Route path='/OrganizationView' component={OrganizationView}/>
                        <Route path='/PositionCategoryTable' component={PositionCategoryTable}/>
                        <Route path='/PositionView' component={PositionView}/>
                        {/*行政区域管理*/}
                        <Route path='/CountryTable' component={CountryTable}/>
                        <Route path='/RegionView' component={RegionView}/>
                        <Route path='/ProfessionalDomainView' component={ProfessionalDomainView}/>
                        {/*租户管理*/}
                        <Route path='/TenantTable' component={TenantTable}/>
                        {/*权限管理*/}
                        <Route path='/FeatureRoleView' component={FeatureRoleView}/>
                        <Route path='/DataRoleManagerView' component={DataRoleManagerView}/>
                        <Route path='/DataAuthorizationView' component={DataAuthorizationView}/>
                        {/*用户管理*/}
                        <Route path='/EnterpriseUserView' component={EnterpriseUserView}/>
                        <Route path='/SupplierUserTable' component={SupplierUserTable}/>
                        <Route path='/ExpertUserTable' component={ExpertUserTable}/>
                        <Route path='/Test' component={Test}/>
                        <Route path='/noAuthorized' component={NoAuthorized}/>
                        <Redirect to={"/login"}/>
                    </Switch>
                </Suspense>
            </Router>

        );
    }
}
